package models;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import play.db.jpa.Blob;
import play.db.jpa.Model;

@Entity
public class Movie extends Model {
	
	public String name;
	public int duration;
	public double rate;
	public String director;
	public Cast cast;
	public Soundtrack soundtrack;
	public Blob image;
	
	@OneToMany
	public List<Comment> comments;
	@OneToMany
	public List<Trailer> trailers;
	@OneToMany
	public List<User> whoLikedList;	
	@ManyToMany
	public List<MovieCategory> categories;
	
	
	/**
	 * @:TODO:test edilmesi gerek
	 * @return
	 */
	public List<Movie> getTopMovies() {
		List<Movie> topMovies = Movie.find("order by rate desc").fetch(5);
		
		return topMovies;
	}

}
